package com.example.pc.greenplants.Personal;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.pc.greenplants.Personal.WDL;
import com.example.pc.greenplants.R;

import java.util.List;

public class WDLAdapter  extends ArrayAdapter<WDL> {
    private  int resourceId;
    public WDLAdapter(Context context, int textViewrRsourceId, List<WDL> objects){
        super(context,textViewrRsourceId,objects);
        resourceId=textViewrRsourceId;
    }
    public View getView(int position, View convertView, ViewGroup parent){
        WDL wdl=getItem(position);//获取当前的personal实例
        View view= LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        ImageView personalImage=(ImageView)view.findViewById(R.id.personal_image);
        TextView personalName=(TextView)view.findViewById(R.id.personal_name);
        personalImage.setImageResource(wdl.getImageId());
        personalName.setText(wdl.getName());
        return view;
    }
}
